package com.metaera.app.ui.adapters;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.metaera.app.R;
import com.metaera.app.data.model.SpecialResponse;
import com.metaera.app.ui.activities.ChoiceTopicDetailsActivity;
import com.metaera.app.utils.image.GlideApp;

import java.util.List;

import androidx.annotation.NonNull;

public class ChoiceTopicAdapter extends BaseQuickAdapter<SpecialResponse.Selected, BaseViewHolder> {

    public ChoiceTopicAdapter(List<SpecialResponse.Selected> data) {
        super(R.layout.item_choice_topic,data);

        setOnItemClickListener((adapter, view, position) -> {
            Context context = view.getContext();
            context.startActivity(ChoiceTopicDetailsActivity.newInstance(context, getItem(position).getId()));
        });
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, SpecialResponse.Selected item) {
        holder.setText(R.id.tv_title, item.getName());

        ImageView ivCover = holder.getView(R.id.iv_cover);
        GlideApp.with(ivCover)
                .load(item.getPic())
                .miniThumb()
                .into(ivCover);
    }

}
